package moddbbackendrevisited.schema;

import java.util.Hashtable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "column")
public class Column {

    private static Hashtable<String, String> typeToMime = new Hashtable<String, String>();

    static {
        typeToMime.put("nchar", "text/plain");
    }

    @XmlAttribute
    public String name;
    @XmlAttribute
    public String type;
    @XmlAttribute
    public String mime;

    public Column() {
    }

    public Column(String name, String type, String mime) {
        this.name = name;
        this.type = type;
        this.mime = mime;

        int i = name.lastIndexOf(';');

        if (i != -1) {
            this.mime = name.substring(i + 1);
            this.name = name.substring(0, i);
        } else {
            if (mime == null) {
                this.mime = "UNKNOWN"; // change to text/plain?
            }
        }
    }
    
}
